package api.txSplash;

import android.content.Context;
import android.view.View;


import java.lang.ref.SoftReference;

public abstract class Splash_API_TT {

    public static String clazz = "com.dotools.toutiaolibrary.TT_Splash";

    private static SoftReference<Splash_API_TT> sf;

    public synchronized static Splash_API_TT getInstance() {

        if (sf == null || sf.get() == null) {
            Object o = null;
            try {
                o = Class.forName(clazz).newInstance();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            if (o != null) {
                sf = new SoftReference<>((Splash_API_TT) o);
                return (Splash_API_TT) o;
            }
        }
        return sf == null ? null : sf.get();
    }
    //showMode 0是正常模式  1是只有部分区域可以点击模式
    //downloadMode 0是直接下载apk  1是会提示下载弹窗
    //isClickEye是否开启点睛
    // clickEyePosition 点睛显示位置 LEFT_BOTTOM = 0 RIGHT_BOTTOM=1 LEFT_TOP=2 RIGHT_TOP=3
    public abstract void LoadSplash(Context context, String appid, String adposid, int showMode, int downloadMode, boolean isClickEye,int clickEyePosition, SplashListener listener);


    public interface SplashListener {
        void onLoaded(View view);

        void onShow(View view, int type);

        void onError(int code, String message);

        void onTimeout();

        void onClicked(View view, int type);

        void onSkip();

        void onTimeOver();
    }

}
